/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author SONY
 */
@Entity
@Table(name = "SaleOrder")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SaleOrder.findAll", query = "SELECT s FROM SaleOrder s"),
    @NamedQuery(name = "SaleOrder.findBySaleOrderID", query = "SELECT s FROM SaleOrder s WHERE s.saleOrderID = :saleOrderID"),
    @NamedQuery(name = "SaleOrder.findByCustomerName", query = "SELECT s FROM SaleOrder s WHERE s.customerName = :customerName"),
    @NamedQuery(name = "SaleOrder.findByShippingAddress", query = "SELECT s FROM SaleOrder s WHERE s.shippingAddress = :shippingAddress"),
    @NamedQuery(name = "SaleOrder.findByShippingPhone", query = "SELECT s FROM SaleOrder s WHERE s.shippingPhone = :shippingPhone"),
    @NamedQuery(name = "SaleOrder.findByOrderDate", query = "SELECT s FROM SaleOrder s WHERE s.orderDate = :orderDate"),
    @NamedQuery(name = "SaleOrder.findByStatus", query = "SELECT s FROM SaleOrder s WHERE s.status = :status"),
    @NamedQuery(name = "SaleOrder.findByTotalPrice", query = "SELECT s FROM SaleOrder s WHERE s.totalPrice = :totalPrice"),
    @NamedQuery(name = "SaleOrder.findByPaymentType", query = "SELECT s FROM SaleOrder s WHERE s.paymentType = :paymentType")})
public class SaleOrder implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "SaleOrderID")
    private Integer saleOrderID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "CustomerName")
    private String customerName;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 150)
    @Column(name = "ShippingAddress")
    private String shippingAddress;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "ShippingPhone")
    private String shippingPhone;
    @Basic(optional = false)
    @NotNull
    @Column(name = "OrderDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date orderDate;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "Status")
    private String status;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "TotalPrice")
    private BigDecimal totalPrice;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 11)
    @Column(name = "PaymentType")
    private String paymentType;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "saleOrderID")
    private Collection<SaleOrderDetail> saleOrderDetailCollection;
    @JoinColumn(name = "MemberID", referencedColumnName = "MemberID")
    @ManyToOne
    private MemberCustomer memberID;

    public SaleOrder() {
    }

    public SaleOrder(Integer saleOrderID) {
        this.saleOrderID = saleOrderID;
    }

    public SaleOrder(Integer saleOrderID, String customerName, String shippingAddress, String shippingPhone, Date orderDate, String status, BigDecimal totalPrice, String paymentType) {
        this.saleOrderID = saleOrderID;
        this.customerName = customerName;
        this.shippingAddress = shippingAddress;
        this.shippingPhone = shippingPhone;
        this.orderDate = orderDate;
        this.status = status;
        this.totalPrice = totalPrice;
        this.paymentType = paymentType;
    }

    public Integer getSaleOrderID() {
        return saleOrderID;
    }

    public void setSaleOrderID(Integer saleOrderID) {
        this.saleOrderID = saleOrderID;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public String getShippingAddress() {
        return shippingAddress;
    }

    public void setShippingAddress(String shippingAddress) {
        this.shippingAddress = shippingAddress;
    }

    public String getShippingPhone() {
        return shippingPhone;
    }

    public void setShippingPhone(String shippingPhone) {
        this.shippingPhone = shippingPhone;
    }

    public Date getOrderDate() {
        return orderDate;
    }

    public void setOrderDate(Date orderDate) {
        this.orderDate = orderDate;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public BigDecimal getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(BigDecimal totalPrice) {
        this.totalPrice = totalPrice;
    }

    public String getPaymentType() {
        return paymentType;
    }

    public void setPaymentType(String paymentType) {
        this.paymentType = paymentType;
    }

    @XmlTransient
    public Collection<SaleOrderDetail> getSaleOrderDetailCollection() {
        return saleOrderDetailCollection;
    }

    public void setSaleOrderDetailCollection(Collection<SaleOrderDetail> saleOrderDetailCollection) {
        this.saleOrderDetailCollection = saleOrderDetailCollection;
    }

    public MemberCustomer getMemberID() {
        return memberID;
    }

    public void setMemberID(MemberCustomer memberID) {
        this.memberID = memberID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (saleOrderID != null ? saleOrderID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SaleOrder)) {
            return false;
        }
        SaleOrder other = (SaleOrder) object;
        if ((this.saleOrderID == null && other.saleOrderID != null) || (this.saleOrderID != null && !this.saleOrderID.equals(other.saleOrderID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.SaleOrder[ saleOrderID=" + saleOrderID + " ]";
    }
    
}
